package com.zzh.muke.urlParser;

import java.io.IOException;
import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class urlParser {

	public static void parse(String url) {
		Document doc;
		String chapter = null;//
		String course = null;//
		String urlSmall = null;

		try {
			doc = Jsoup.connect(url).get();
			// System.out.println(doc);
			for (Element ele : doc.select("div.mod-chapters>div.chapter")) {
				// System.out.println(ele.text());
				chapter = ele.select("h3").text();// get chapter name
				System.out.println(chapter);
				for (Element el : ele.select("ul.video>li>a")) { // get every
																	// course
																	// url page
					course = el.text().replace("开始学习", "").trim();// get course
																	// name
					urlSmall = el.attr("href");// get half url
					url = "http://www.imooc.com" + urlSmall;
					System.out.print("    " + course);
					System.out.println(">>" + url);
					videoParse(url);

				}

			}

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	public static void videoParse(String url){
		String trueUrl=null;
		try {
			URL UR = new URL("url");
			Document doc = Jsoup.parse(UR, 1000000);
			
		//	Document doc = Jsoup.connect(url).get();
			doc.getElementById("video-box");
			System.out.println(doc.getElementById("video-box")); 
			Elements eles = doc.select("video");
			System.out.println(eles.size()); 
			for(Element ele:eles){
				trueUrl = ele.attr("scr");
				System.out.println("真实地址："+trueUrl);
				
			}
			
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
		
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//parse("http://www.imooc.com/learn/712");
		videoParse("http://www.imooc.com/video/3370");
	}

}
